import React, { Component } from 'react'
import styles from './PublishNews.module.scss'
import placeholder from './../../images/placeholder.jpg'

export default class PublishNews extends Component {

  constructor(props) {
    super(props);
    this.state={
    }
    this.onItem = this.onItem.bind(this)
  }

  onItem(item) {
    this.props.onItem(item)
  }

  render() {
    const { datas } = this.props
    return (
      <div className={styles.news_list}>
        <div className={styles.title_div}>
          <span>最新</span>发布
        </div>
        <div className={styles.news}>
          {datas && datas.map((item, index) => {
            return (
              <div key={index} className={styles.news_item}>
                <img src={item.img_url || placeholder} alt=""/>
                <span onClick={() => this.onItem(item)}>{item.title || item.name || ''}</span>
              </div>
            );
          })}
        </div>
      </div>
    )
  }
}
